
export class YunioXml {
  public static DocType(root: string, publicId: string, systemId: string): DocumentType {
    return document.implementation.createDocumentType(root, publicId, systemId);
  }
  public static Parse(xmltext: string): YunioXml {
    const convert = new DOMParser();
    return new YunioXml(convert.parseFromString(xmltext, "text/xml"));
  }

  doc: XMLDocument;
  constructor(root: string | XMLDocument, namespace?: string, doctype?: DocumentType) {
    if (typeof root == "string") this.doc = document.implementation.createDocument(namespace, root, doctype);
    else this.doc = root;
  }
  public ToString(): string {
    const convert = new XMLSerializer();
    return convert.serializeToString(this.doc);
  }
}